let job_rank = echarts.init(document.getElementById('job_rank'));
let abroad_rank = echarts.init(document.getElementById('abroad_rank'));
let promotion_rank = echarts.init(document.getElementById('promotion_rank'));

let job_option = {
    xAxis: {
        type: 'category',
        data: [],
        axisLabel: {
            formatter: function (value) {
                return value.split("").join("\n");
            }
        }
    },
    yAxis: {
        type: 'value'
    },
    series: [{
        data: [],
        label: {
            show: true,
            position: 'insideUp'
        },
        type: 'bar'
    }]
};
let abroad_option = {
    xAxis: {
        type: 'category',
        data: [],
        axisLabel: {
            formatter: function (value) {
                return value.split("").join("\n");
            }
        }
    },
    yAxis: {
        type: 'value'
    },
    series: [{
        data: [],
        label: {
            show: true,
            position: 'insideUp'
        },
        type: 'bar'
    }]
};
let promotion_option = {
    xAxis: {
        type: 'category',
        data: [],
        axisLabel: {
            formatter: function (value) {
                return value.split("").join("\n");
            }
        }
    },
    yAxis: {
        type: 'value'
    },
    series: [{
        data: [],
        label: {
            show: true,
            position: 'insideUp'
        },
        type: 'bar'
    }]
};

$.ajax({
    type: "GET",
    url: '/schoolRank/job',
    success: function (res) {
        for (let i = 0; i < res.length; i++) {
            job_option.series[0].data.push(res[i].job);
            job_option.xAxis.data.push(res[i].schoolName);
            job_rank.setOption(job_option);
        }
    },
    cache: false
});
$.ajax({
    type: "GET",
    url: '/schoolRank/abroad',
    success: function (res) {
        for (let i = 0; i < res.length; i++) {
            abroad_option.series[0].data.push(res[i].abroad);
            abroad_option.xAxis.data.push(res[i].schoolName);
            abroad_rank.setOption(abroad_option);
        }
    },
    cache: false
});
$.ajax({
    type: "GET",
    url: '/schoolRank/postgraduate',
    success: function (res) {
        for (let i = 0; i < res.length; i++) {
            promotion_option.series[0].data.push(res[i].postgraduate);
            promotion_option.xAxis.data.push(res[i].schoolName);
            promotion_rank.setOption(promotion_option);
        }
    },
    cache: false
});